package com.zeus.base.smscenter.shiro;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.Subject;

/**
 * Created by ShanFei on 2017-03-03.
 * 获取cas返回过来的对象信息
 */
public class ShiroUtil {
    public static Subject getShiroSubject(){
        Subject subject = SecurityUtils.getSubject();
        return subject;
    }

    /**
     * Object principal对象是可以获取到当前登录账号
     * 第二个对象是一个List集合其中0元素是当前登录账号,1元素是一个map集合,这里就存放了我们cas服务给我返回的用户信息
     * 拦截器判断是否有登录就用第一个Object判断是否有null即可
     * @param subject
     * @return
     */
    public static Object getPrincipal(Subject subject){
        Object principal = subject.getPrincipal();
        return principal;
    }
    public static PrincipalCollection getPrincipalCollection(Subject subject){
        PrincipalCollection principals = subject.getPrincipals();
        return principals;
    }
}
